<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * Mailer short summary.
 *
 * Mailer description.
 *
 * @version 1.0
 * @author xianbin
 */
class Mailer
{
    public $from;
    public $from_name;
    public $address;
    public $address_name;
    public $subject;
    public $body;
    public $altbody="";
    public $ishtml=false;
    public $addAttachment="";


    private $CI;
    public function __construct()
    {
        $this->CI=&get_instance();

        $this->CI->load->library('PHPMailer/PHPMailer.php');
        $this->CI->load->library('PHPMailer/SMTP.php');
    }
    public function send()
    {
        date_default_timezone_set('Asia/Shanghai');
        $mail=new PHPMailer();
        $mail->isSMTP();//使用smtp方式发送
        $mail->CharSet="UTF-8";
        $mail->Mailer="smtp";
        $mail->Host="smtp.163.com";
        $mail->SMTPAuth=true;
        $mail->Username="lxb932979339@163.com";
        $mail->Password="liuxianbin123!";
        $mail->From=$this->from;
        $mail->FromName=$this->from_name;
        $mail->addAddress($this->address,$this->address_name);
        $mail->addAttachment($this->addAttachment);//添加附件
        $mail->isHTML($this->ishtml);
        $mail->Subject=$this->subject;
        $mail->Body=$this->body;
        $mail->AltBody=$this->altbody;
        $mail->setLanguage('zh_cn');
        if(!$mail->send())
        {
            return array('statu'=>false,'msg'=>$mail->ErrorInfo);
        }
        else
        {
            return array('statu'=>true,'one'=>$this->addAttachment);
        }
    }
}